<%--
 *  File:    SystemMenuConfigTree.jsp
 *  @Author: Michael Zhao 
 *  Date:    2001/12/14
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>


<%@ page contentType = "text/html;charset=UTF-8" %>

<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  
  String strModuleName = "IMG";    
  String privilegeCode = "Z0812";
%>



<%
  //get curuserinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");  
  String strCurOrgName = (String)CurUserInfo.get("orgname");
  Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
  if(nCurOrgId == null)
  {
    nCurOrgId = new Integer(-1234567);
  }  
	int grade = -1;
	if(CurUserInfo.get("grade") != null)
 	{
 	  grade = ((Integer)CurUserInfo.get("grade")).intValue();
 	}
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="systemmenu"/>
<%
  Vector systemmenu = (Vector)pageContext.getAttribute("systemmenu");
  Vector allapp = (Vector)pageContext.getAttribute("allapp");
  
  Integer app = (Integer)pageContext.getAttribute("app");
 
    
  if(systemmenu == null)
  {
    systemmenu = new Vector();
  }   
  if(allapp == null)
  {
    allapp = new Vector();
  }
 
 


  OvalTree initTree = new OvalTree(systemmenu,"privilegeid","parentprivid","grade");
  initTree.setRecursiveLimit(2000);
  Vector menuTree = (Vector)initTree.getTreeVector(new Integer(-1000),1);  
  
%>
 <%
	Vector systemmenudel =(Vector)pageContext.getAttribute("systemmenudel");
    if(systemmenudel!=null && systemmenudel.size()>0)
	{
		out.print("<script language='javascript'>alert('"+message.getMessageDesc("CAN_NOT_DELETE_SYSTEM")+"');</script>");
        
	}
	
	
	%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<SCRIPT language=JavaScript1.2 src="../css/menu.js"></SCRIPT>
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript">
parent.rightFrame.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function page_view(id,grade,isbottom,parentid)
{
  document.cform.privilegeid.value = id;
  document.cform.grade.value = grade; 
  document.cform.isbottom.value = isbottom;  
  document.cform.parentprivid.value = parentid;  
    
  if(id == null || id.length == 0 || id == "" || id < 0)
  {
    return;
  }
  var viewmenu = "SystemMenuConfigInfo.jsp?<%= OvalTools.randomURL() %>&privilegeid=" + id + "&languagecode=" + "<%= strLanguageCode %>"+"&app=" + document.cform.appid.value;
  parent.rightFrame.location.href = viewmenu;   
}
function page_addnewchild()
{
  var id = document.cform.privilegeid.value;
  if(id == null || id.length == 0 || id == "" || id < 0)
  {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");    
    return;
  }
  var gradev = new Number(1) + new Number(document.cform.grade.value);
  var newchildurl = "SystemMenuConfigNew.jsp?<%= OvalTools.randomURL() %>&parentprivid=" + id + "&languagecode=" + "<%= strLanguageCode %>" + "&grade=" + gradev;
  parent.rightFrame.location.href = newchildurl;   
}
function page_edit()
{
  var id = document.cform.privilegeid.value;
  if(id == null || id.length == 0 || id == "" || id < 0)
  {
    alert("<%= message.getMessageDesc(" MUST_SELECT_ONE_RECORD_TO_EDIT") %>");
    return;
  }
  var editurl = "SystemMenuConfigEdit.jsp?<%= OvalTools.randomURL() %>&privilegeid=" + id + "&languagecode=" + "<%= strLanguageCode %>" +"&app=" + document.cform.appid.value;
  parent.rightFrame.location.href = editurl;  
}

function page_new()
{
   var editurl = "SystemMenuConfigNew.jsp?<%= OvalTools.randomURL() %>&languagecode=" + "<%= strLanguageCode %>" +"&app=" + document.cform.appid.value;
  parent.rightFrame.location.href = editurl; 
}
function page_delete()
{
  var id = document.cform.privilegeid.value;
  var isbottom = document.cform.isbottom.value;  
  if(id == null || id.length == 0 || id == "" || id == "-1")
  {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");    
    return;
  }
  if(!(isbottom == "Y" || isbottom == "y"))
  {
    alert("<%= message.getMessageDesc("NOT_LEAF",label.getLabelName("L_Menu",false)) %>");
    return;
  }
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
  document.cform.actionname.value = "delete";
  document.cform.target = "_parent";  
  isRunning = true;
  document.cform.submit();
}
function page_select()
{
  
 <%--[SCRIPT]   var app = document.cform.appid.value;  [SCRIPT]--%>
  <%--[SCRIPT]  alert(app);  [SCRIPT]--%>
  document.cform.app.value = document.cform.appid.value;
 <%--[SCRIPT]   self.location.herf = "SystemMenuConfigFrm.jsp?app=" + app;  [SCRIPT]--%>
  cform.action = "SystemMenuConfigTree.jsp?<%= OvalTools.randomURL() %>";
  cform.target = "_self";
  isRunning = true;
  cform.submit();  
}
function page_editsys()
{
  var id = document.cform.appid.value;
  var editsys = "SystemEdit.jsp?<%= OvalTools.randomURL() %>&app=" + id + "&languagecode=" + "<%= strLanguageCode %>";
  parent.rightFrame.location.href = editsys; 
}

function page_deletesys()
{
	var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
    if(!flag)
    return;
	cform.actionname.value = "deletesys";
  	cform.target = "_self";
  	isRunning = true;
  	cform.submit();
}
function page_callprocedure()
{	
    cform.actionname.value = "callprocedure";
  	cform.target = "_self";
  	isRunning = true;
  	cform.submit();
}


</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
  <form name="cform" method="post" action="../Dispatcher">
       <input type="hidden" name="pagename" value="systemmenu">
       <input type="hidden" name="actionname">
       
       <input type="hidden" name="privilegeid">
       <input type="hidden" name="isbottom">
       <input type="hidden" name="grade">
       <input type="hidden" name="parentprivid">
	   <input type="hidden" name="app" value="<%=JspHelper.filterNull(app)%>">
  <tr> 
    <td valign="top"> 
      <table border="0" cellspacing="1" width="100%">
      <tr> 
        <td><a onclick="page_callprocedure()"><%= label.getLabelName("L_System") + label.getLabelName("L_Colon") %></a><custom:select optionsName="allapp" optionValueKey="appid" optionInnerTextKey="applicationname" property="appid"/>
       <a href="javascript:page_select();"><img src="../images/<%= strLanguageCode %>/go.gif" border="0"></a>
      </td>
     </tr>
      </table>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" height="80%">
        <tr> 
          <td colspan="-1" class="deepblue-left"><img src="../images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
            <%= label.getLabelName("L_Menu") + label.getLabelName("L_Colon") %></td>
        </tr>
        <tr> 
          <td class="spe-td">                         
		  <div id=div2 style="OVERFLOW: scroll; WIDTH: 234px; HEIGHT: 465px">
   <%
   if(menuTree.size() != 0)
   {
     int nTreeLevel = 0;
     int nLevelDif = 0;
     int nTopLevel = 0;
     int nEndLevel = 0;
     String strIMG = "TreeAdd.gif";
     for(int i = 0;i < menuTree.size();i++)
     {
       HashMap temp = (HashMap)menuTree.elementAt(i);
       
       int nNext = ((Integer)temp.get("next")).intValue();
       String strLevelCode = (String)temp.get("levelcode");       
       nTreeLevel = ((Integer)temp.get("grade")).intValue()+ nLevelDif;
       if(((Boolean)temp.get("ismin")).booleanValue())
       {
         strIMG = "TreeSub.gif";
       }
       else
       {
         strIMG = "TreeAdd.gif";
       }
       for(int j = 0;j <= -nNext;j++)
       {
         if(i != 0)
         {
   %>
            </div>                   
           </td>
          </tr>               
         </table>
   <%    
         }
       }
       
       if(((Boolean)temp.get("ismax")).booleanValue())
       {
         nTopLevel = ((Integer)temp.get("grade")).intValue();
         nTreeLevel = 1;
         nLevelDif = ((Integer)temp.get("grade")).intValue() - 1;
   %> 

      <table cellspacing="0" width="100%">     
       <tr> 
        <td class="TreeClass1"><a href="javascript:void(0)" <%if(!((Boolean)temp.get("ismin")).booleanValue()){%>onClick="expandIt(cform,'KB<%=JspHelper.filterNull( strLevelCode )%>','../images/<%= strLanguageCode %>/'); return false"<%}%>><img name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" src="../images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" height="11" border="0" ></a><a href="javascript:page_view('<%=JspHelper.filterNull( temp.get("privilegeid") )%>','<%=JspHelper.filterNull( temp.get("grade") )%>','<%=JspHelper.filterNull( temp.get("isbottom") )%>','<%=JspHelper.filterNull( temp.get("parentprivid") )%>')"><%=JspHelper.filterNull( temp.get("menuname"))%></a> 
         <div class=child<%=JspHelper.filterNull( strLevelCode )%> id=KB<%=JspHelper.filterNull( strLevelCode )%>Child style="display:none"> 
   <%   
       } 
       if(!((Boolean)temp.get("ismax")).booleanValue() && !((Boolean)temp.get("ismin")).booleanValue())
       {
   %>
          <table cellspacing="0" width="100%">     
           <tr> 
            <td class="TreeClass<%=JspHelper.filterNull( nTreeLevel )%>"><a href="#" onClick="expandIt(cform,'KB<%=JspHelper.filterNull( strLevelCode )%>','../images/<%= strLanguageCode %>/'); return false"><img src="../images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" width="11" height="11" name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" border="0"></a><a href="javascript:page_view('<%=JspHelper.filterNull( temp.get("privilegeid") )%>','<%=JspHelper.filterNull( temp.get("grade") )%>','<%=JspHelper.filterNull( temp.get("isbottom") )%>','<%=JspHelper.filterNull( temp.get("parentprivid") )%>')"><%=JspHelper.filterNull( temp.get("menuname"))%></a>
            <div class=child<%=JspHelper.filterNull( strLevelCode )%> id=KB<%=JspHelper.filterNull( strLevelCode )%>Child style="display:none"> 
   <%
       }
       if(!((Boolean)temp.get("ismax")).booleanValue() && ((Boolean)temp.get("ismin")).booleanValue())
       {
   %>
          <table cellspacing="0" width="100%">     
           <tr> 
            <td class="TreeClass<%=JspHelper.filterNull( nTreeLevel )%>"><a href="javascript:void(0)"><img src="../images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" width="11" height="11" name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" border="0"></a><a href="javascript:page_view('<%=JspHelper.filterNull( temp.get("privilegeid") )%>','<%=JspHelper.filterNull( temp.get("grade") )%>','<%=JspHelper.filterNull( temp.get("isbottom") )%>','<%=JspHelper.filterNull( temp.get("parentprivid") )%>')"><%=JspHelper.filterNull( temp.get("menuname"))%></a>
             <div>  
   <%
       }
       nEndLevel = ((Integer)temp.get("grade")).intValue();
     }     
     //close the tag
     for(int h = 0; h <= nEndLevel - nTopLevel;h++)
     {
   %>
              </div>     
             </td>
            </tr>    
           </table>              
   <%  
     }
   }          
   %>
      </div>
          </td>
        </tr>
        <tr> 
          <td class="td-listrom">&nbsp;</td>
        </tr>
      </table>
      <table border="0" cellspacing="1" width="100%">
        <tr>
          <td class="td_center"><a onclick="page_new()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
          <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
          <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a></td>
        </tr>
		<tr> 
          <td class="td_center"><a onclick="parent.rightFrame.location.href='SystemNew.jsp?<%= OvalTools.randomURL() %>';"><custom:button type="1" label="L_NewSys" imgsrc="NewSys.gif" border="0" style="width:60"/></a> <a onclick="page_editsys()"><custom:button type="1" label="L_EditSys" imgsrc="EditSys.gif" border="0" style="width:60"/></a> <a onclick="page_deletesys()"><custom:button type="1" label="L_DelSys" imgsrc="DelSys.gif" border="0" style="width:60"/></a> 
		  </td>
       </tr>
        </table>
    </td>
  </tr>
    </form> 
</table>

    </body>
<script language="JavaScript">  
  var ht = document.body.clientHeight - 100;
  if(ht < 0 )
    ht = 0;
  div2.style.height= ht;
</script>
    <SCRIPT language=JavaScript1.2>initIt(cform,'../images/<%= strLanguageCode %>/');</SCRIPT>
	
</html>


